<script type="text/javascript">
    $(document).ready(function(){
        baris = $('.jenisMemberList').length;
        var max = <?php echo "$countJenisMember";?>;
        $('.tambahBaris').click(function(){
            if(baris < max){
                var string = "<fieldset class='field-group baris'>"+
                    "<label>Jenis Member</label>"+
                    "<select name='jenisMember[]'>"+
                    "<option value=''>Pilih jenis member</option>"+
                       <?php
                         foreach ($listJenisMember as $rowz){
                       ?>
                            "<option value='<?php echo $rowz['id'];?>'><?php echo $rowz['nama'];?></option>"+           
                       <?php                
                         }
                       ?>
                    "</select>"+
                    "<input type='button' onClick='removeMe(this)' class='del_button' value='Hapus'>"+
                    "</fieldset>";
                $('.jenisMember').append(string);
            }
            baris++;
        })
    })
    
    function removeMe(el){
        var parent = el.parentNode;
        parent.parentNode.removeChild(parent);
        baris = 1;
    }
</script>
<div class="data-input">
    <fieldset>
        <legend><?php echo "$formTitle";?></legend>
        <?php
          echo form_open_multipart($subLink, '');
        ?>
        <table width="100%">
          <tr>
            <td valign="top" width="50%">
                <label>Nama</label><?php echo form_input("nama", "", "id='nama'");?>
                <fieldset class="field-group">
                    <label>Tgl. Lahir</label>
                    <?php echo form_input("tglLahir", "", "class='tanggal datepicker-input' id='tglLahir'");?>
                </fieldset>
                <fieldset class="field-group">
                    <label>Jenis Kelamin</label>
                    <label class="field-option"><?php echo form_radio("jeKel", "L",false,"id='laki-laki'")?>Laki-laki</label>
                    <label class="field-option"><?php echo form_radio("jeKel", "P",false,"id='perempuan'")?>Perempuan</label>
                </fieldset>
                <label>Alamat</label><?php echo form_input("alamat", "", "id='alamat'");?>
                <label>No. Telepon</label><?php echo form_input("noTelp", "", "id='noTelp' maxsize='15'");?>
                <label>Pekerjaan</label>
                <select name="pekerjaan" id="pekerjaan">
                    <option value="">Pilih pekerjaan</option>
                    <?php
                         foreach ($listPekerjaan as $row){
                    ?>        
                        <option value="<?php echo $row['id'];?>"><?php echo $row['nama'];?></option>
                    <?php     
                         }
                    ?>
                </select>
            </td>
            <td valign="top">
                <?php echo form_button("", "Tambah", "class='tambahBaris'");?>
                <div class="jenisMember">
                    <fieldset class="field-group jenisMemberList baris">
                        <label>Jenis Member</label>
                        <select name="jenisMember[]" id="jenisMember">
                                <option value="">Pilih jenis member</option>
                            <?php
                                foreach ($listJenisMember as $rows){
                            ?>
                                <option value="<?php echo $rows['id'];?>"><?php echo $rows['nama'];?></option>
                            <?    
                                }
                            ?>
                        </select>  
                    </fieldset>
                </div>
                <fieldset class="field-group">
                  <label>Foto</label><?php echo form_upload('userfile');?>
                </fieldset>
                <fieldset class="input-process">
                    <?php
                      echo form_submit("add", "Simpan", "class='button' style='margin-right:2px'");
                      echo form_button('Batal', 'Batal', 'class=button onClick='."javascript:location.href='".base_url()."index.php/member/'".'');
                    ?>
                </fieldset>
            </td>
          </tr>
        </table>
        <?php
          echo form_close();
        ?>
    </fieldset>    
</div>
